package com.test.case3;

import java.util.concurrent.BlockingQueue;

/**
 * @Author:wyf
 * @Description:生产消费者模式当中的生产者
 * @Date:Created in 9:48 2021/6/29
 * @Modified By:
 */
public class Producer implements  Runnable{
    private final BlockingQueue sharedQueue;

    public Producer(BlockingQueue sharedQueue){
        this.sharedQueue = sharedQueue;
    }
    @Override
    public void run() {
        for(int i=0; i<50; i++){
            System.out.println("Chefs Produced: " + i+" dish ");
            try {
                sharedQueue.put(i);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            //sharedQueue.add(i);
        }

    }
}
